/* @(#)GSBalPayRecvManageAddSaveAction.java
 * 
 *  Project:GS
 *  
 *  Modify  Information:
 *  ===============================================
 *   Author          Date            Description
 *  -------------- ---------------  ---------------
 *  Jenny  Li      2006-5-16          新增
 *  Jenny  Li      2006-6-22         修改返回的信息
 * Copyright Notice:
 * =============================================================================
 *    Copyright (c) 2001-2006 Beijing HiTRUST Technology Co., Ltd. 1808 Room, 
 *        Science & Technology Building, No. 9 South Street, Zhong Guan Cun, 
 *        Haidian District, Beijing ,100081, China All rights reserved.
 *
 *    This software is the confidential and proprietary information of
 *        Beijing HiTRUST Technology Co., Ltd. ("Confidential Information").
 *        You shall not disclose such Confidential Information and shall use it
 *        only in accordance with the terms of the license agreement you entered
 *        into with HiTRUST.
 *
 * Warning:
 * =============================================================================
 *
 */
package com.hitrust.gs.action;

import java.util.HashMap;

import com.hitrust.gs.bean.GSOperatorBean;
import com.hitrust.gs.business.GSOrderDeptInfoProcessor;
import com.hitrust.gs.business.GSPayReceiveProcessor;
import com.hitrust.gs.form.GSBalPayRecvAddForm;
import com.hitrust.gs.lib.GSBaseConstants;
import com.hitrust.gs.lib.GSLogWriter;
import com.hitrust.gs.service.GSBaseAction;
import com.hitrust.gs.service.GSBaseForm;
import com.hitrust.gs.util.exception.GSException;
import com.hitrust.gs.vo.GSBalPayRecvAddVO;

/**
 * @author JennyLi
 *
 */
public class GSBalPayRecvManageAddSaveAction extends GSBaseAction {

    /* (non-Javadoc)
     * @see com.hitrust.gs.service.GSBaseAction#execute(com.hitrust.gs.service.GSBaseForm)
     */
    public String execute(GSBaseForm aForm) throws Exception {
        
        GSBalPayRecvAddForm tForm = (GSBalPayRecvAddForm)aForm;
        GSBalPayRecvAddVO tVO = new GSBalPayRecvAddVO();
        try{
//            tVO.deptId = tForm.getADeptId();
            tVO.deptId = tForm.getAddDeptId();
            tVO.deptCategory = tForm.getAddDeptCategory();
            tVO.balanceYM = tForm.getAddBalanceYM();
            tVO.feeTypeNo = tForm.getAddFeeTypeNo();
            tVO.notes = tForm.getAddNotes();
            tVO.provider = tForm.getAddProvider();
            tVO.sum = tForm.getAddSum();
            tVO.payType = tForm.getAddPayType();
            tVO.payDate = tForm.getAddPayDate();
            tVO.principal = tForm.getAddPrincipal();
            GSPayReceiveProcessor tPayRecvProc = new GSPayReceiveProcessor();
            
            GSOperatorBean tOperBean = (GSOperatorBean)tForm.getSession().getAttribute(GSBaseConstants.LOGIN);
            boolean tFlag = tPayRecvProc.addPayRecvInfo(tVO,tOperBean.getGs_oper_id());
//            String msg = "";
//            if(tVO.deptCategory.equals(GSBaseConstants.BALANCE_ORDERDEPT_TYPE)){
//                msg = "应收";
//            }else{
//                msg = "应付";
//            }
            if(tFlag){
                tForm.getRequest().setAttribute("message","新增数据成功!");
            }else{
                tForm.getRequest().setAttribute("message","新增数据失败!");
            }
            tForm.getRequest().setAttribute("requery","true");
            //取得当前操作员可查询的订货单位和送货地址
            GSOrderDeptInfoProcessor tProc = new GSOrderDeptInfoProcessor();
            HashMap tMap = tProc.getOrderDeptInfoOfBusOper(tOperBean.getGs_oper_org_id());
            aForm.getRequest().setAttribute("orderdept",tMap);
        }catch(GSException ge){
            tForm.getRequest().setAttribute("action","A180301.do");
            throw ge;
        }catch(Exception e){
            tForm.getRequest().setAttribute("action","A180301.do");
            GSLogWriter.error(this,e.toString());
            throw e;
        }
        return GSBaseConstants.FORWARD_SUCCESS;
    }

}
